<!--<!DOCTYPE html>-->
<!--<html>-->
<!--<head>-->
<!--    <title>{$platform.name}</title>-->
<!--    <link href="/static/css/framework-font.css" rel="stylesheet"/>-->
<!--    <script src="/static/js/jquery-2.1.1.js"></script>-->
<!--    <script src="/static/bootstrap/js/bootstrap.js"></script>-->
<!--    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>-->

<!--    <script src="/static/js/jquery.cookie.js"></script>-->
<!--    <link href="/static/css/framework-theme.css" rel="stylesheet"/>-->
<!--    &lt;!&ndash;    <script src="/static/js/framework-ui.js"></script>&ndash;&gt;-->
<!--    &lt;!&ndash;    <script src="/static/js/framework-clientdata.js"></script>&ndash;&gt;-->

<!--    &lt;!&ndash;弹框js&ndash;&gt;-->
<!--    <script src="/static/js/yii.js"></script>-->

<!--    &lt;!&ndash;引用layui弹框插件&ndash;&gt;-->
<!--    <script src="/static/layui/layui.all.js"></script>-->
<!--    <script src="/static/layui/layui.js"></script>-->
<!--    <link href="/static/layui/css/layui.css" rel="stylesheet"/>-->
<!--    <script src="/static/layui/lay/modules/layer.js"></script>-->


<!--    &lt;!&ndash;    配置select多选相关&ndash;&gt;-->
<!--    &lt;!&ndash;    <script src="/static/layui/dist/xm-select.js"></script>&ndash;&gt;-->


<!--        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}-->

<!--    <script src="/static/build/tracking-min.js"></script>-->
<!--    <script src="/static/build/data/face-min.js"></script>-->
<!--    <script src="/static/build/data/eye-min.js"></script>-->
<!--    <script src="/static/build/data/mouth-min.js"></script>-->
<!--</head>-->
<body>
<style>
    html, body {
        background-color: #FFF !important;
    }

    .modal-body {
        background-color: #fff;
        padding: 15px
    }

    .page-header {
        margin-top: 15px !important;
    }

    .geographic input {
        width: 100px !important;
        float: left;
        margin-right: 15px;
    }

    .new-content {
        padding: 15px 0px
    }

    .config_img {
        width: 45px;
        height: 45px;
        margin-top: 15px;
    }
</style>

<div class="modal-body">


    <div class="modal-header">

        <div class="assistant_header">
            <button type="button" class="close" data-dismiss="modal" close="true">
                <span aria-hidden="true">×</span>
            </button>
            <h4 class="modal-title">
                <span class="fa fa-legal"></span>&nbsp;修改分类
            </h4>
        </div>
    </div>

    <div class="new-content">
        <form class="form-horizontal layui-form">

            <input type="hidden" name="pid" value="{$pid}">
            {if condition="$pid eq 0"}
            <div class="form-group">
                <label class="col-sm-2 control-label">*景区名称:</label>
                <div class="col-sm-8">
                    <select name="colony_id" lay-verify="colony_id" lay-filter="colony_id" class="select"
                            lay-search="">
                        <option value="">请选择景区</option>
                        {volist name="community" id="vo"}
                        <option value="{$vo.id}" {if condition="$detail['colony_id'] eq $vo['id']"} selected {/if}>{$vo.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-2 control-label">*所属栏目:</label>
                <div class="col-sm-8">
                    <select name="nav_id" lay-verify="nav_id" lay-filter="nav_id" class="select"
                            lay-search="">
                        <option value="">请选择栏目</option>
                        {volist name="nav" id="vo"}
                        <option value="{$vo.id}" {if condition="$detail['nav_id'] eq $vo['id']"} selected {/if} >{$vo.name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            {/if}

            <div class="form-group">
                <label class="col-sm-2 control-label">*所属模型:</label>
                <div class="col-sm-8">
                    <select name="type" lay-verify="type" lay-filter="type" class="select"
                            lay-search="">
                        <option value="">请选择模型</option>
                        {volist name="type" id="vo"}
                        <option value="{$key}" {if condition="$detail['type'] eq $key"} selected {/if} >{$vo}</option>
                        {/volist}
                    </select>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-2 control-label">*分类名称:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="name" placeholder="分类名称" value="{$detail.name}">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">副标题:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="subtitle" placeholder="副标题" value="{$detail.subtitle}" >
                </div>
            </div>

            <div class="form-group js_photos">
                <label class="col-sm-2 control-label"> *图标</label>
                <div class="col-sm-8 logo">
                    <div class="input-group ">
                        <input type="file" name="" class="do_upload" data-val="thumb"  style="display: none">
                        <input type="text" class="form-control thumb" name="thumb" disabled="" value="{$detail.thumb}" >
                        <input type="hidden" class="form-control thumb" name="thumb" value="{$detail.thumb}" >
                        <span class="group-span-filestyle input-group-btn" tabindex="0">
                                <label class="btn btn-default id_photos" data-original-title="" title="">
                                    <span class="glyphicon glyphicon-folder-open"></span>
                                    上传
                                </label>
                            </span>
                        </span>
                    </div>

                    {if condition="$detail['thumb'] eq ''"}
                    <img class="config_img" src="/static/images/nopic-107.png" >
                    {else/}
                    <img class="config_img" src="{$detail.thumb}" >
                    {/if}

                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">排序:</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" name="sort" placeholder="排序" value="{$detail.sort}" >
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">状态:</label>
                <div class="col-sm-8">
                    <select name="status">
                        <option value="1" {if condition="$detail['status'] eq 1"} selected {/if}>启用</option>
                        <option value="2" {if condition="$detail['status'] eq 2"} selected {/if}>禁用</option>
                    </select>
                </div>
            </div>

            <input type="hidden" class="form-control" name="id"  value="{$detail.id}" >
        </form>

    </div>
    <div class="assistant_button">
        <button type="button" class="layui-btn layui-btn-primary js_quit" close="true">取消</button>
        <!--        <button type="button" class="btn btn-primary btn-sm js_add" _event="add" data-id="0" data-name="">保存</button>-->
        <button type="button" class="layui-btn js_add">保存</button>
    </div>

</div>


<script>

    var newModal = new yii.modal();

    $(".id_photos").click(function () {
        $(this).parent().parent().find(".do_upload").click();
    });

    $('.js_photos').on('change','.do_upload',function(){
        var content = $(this).attr("data-val");
        var formData = new FormData();
        var name = $($(this)).val();
        var files = $($(this))[0].files[0];
        formData.append("file", files);
        formData.append("name", name);
        //另外加的参数
        formData.append("act", "PostImg");
        // var index = layer.msg('正在提交中....');

        $.ajax({
            url: "{:URL('common/upload/ad_upload')}",
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            dataType: 'json',
            success:function (res) {
                $("."+content).val(res.path);
                $("."+content).find("img").attr("src",res.path);
            }
            ,error:function (res) {
                alert('错误');
            }
        });
    })

    layui.use(['form', 'layedit', 'tree', 'util', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer;
        var layedit = layui.layedit;
        var tree = layui.tree;
        var util = layui.util;
        var laydate = layui.laydate;

        //获取栏目
        form.on('select(colony_id)', function (data) {
            //触发联动
            var id = data.value;
            console.log(id);
            $.ajax({
                type: 'post',
                url: "{:URL('common/together/findNav')}",
                data: {community_id: id},
                dataType: 'JSON',
                success: function (res) {
                    var data = res.data;
                    //生成楼栋信息
                    var html = '<option value="">请选择栏目</option>';
                    $.each(data, function(e,v){
                        html +='<option value="'+v.id+'">'+v.name+'</option>';
                    });
                    $('select[name="nav_id"]').html(html);
                    form.render('select');


                },
                error: function (res) {
                }
            });
        });



        $(".js_add").click(function () {
            var data = $("form").serializeArray();
            $.ajax({
                type: 'post',
                url: "{:URL('community/article/doClass')}",
                data: data,
                dataType: 'JSON',
                success: function (res) {
                    if (res.code != 0) {
                        layer.alert(res.msg);
                    } else {
                        window.location.href = "{:URL('community/article/index')}?pid={$pid}\"";
                    }
                },
                error: function (res) {

                }
            });

        })


        layui.form.render('select');
        form.render();


    });
</script>

</body>
</html>